#pragma once



class CppRobot
{
public:
	inline void keyPress(int key, int duration = 50)
	{
		keyDown(key);
		Sleep(duration);
		keyUp(key);
	}

	inline void keyDown(int key)
	{
		INPUT input;
		memset(&input, 0, sizeof(INPUT));
		input.type = INPUT_KEYBOARD;
		input.ki.wVk = key;

		SendInput(1, &input, sizeof(INPUT));
	}

	inline void keyUp(int key)
	{
		INPUT input;
		memset(&input, 0, sizeof(INPUT));
		input.type = INPUT_KEYBOARD;
		input.ki.wVk = key;
		input.ki.dwFlags = KEYEVENTF_KEYUP;

		SendInput(1, &input, sizeof(INPUT));
	}
};
